<script setup>
import {reactive, ref} from "vue";

const props = defineProps({
  list: {
    type: Array,
    required: true,
    default: ()=>[]
  },
  handleClick: {
    type: Function,
    required: false,
    default: ()=>(index)=>{console.log(index)}
  }
});

let currentItem = reactive({
  id: 10
});
function click(l) {
  for (let index in l) {
    currentItem[index] = l[index];
  }
  props.handleClick(l);
}
</script>
<template>
  <div class="directory">
    <div class="title-1" :class="currentItem!==null?(currentItem.id===l.id?'click-title-1':''):''" v-for="(l, i) in list" @click="click(l)">
      {{l.name}}
    </div>
  </div>
</template>
<style scoped>
.directory {
  padding: 0 50px 0 30px;
}

.title-1 {
  color: inherit;
  user-select: none;
  border-radius: 10px;
  width: 120px;
  height: 40px;
  line-height: 40px;
  transition: all 0.1s ease-in-out;
  text-align: left;
  padding: 0 15px;
  margin-top: 5px;
}
.title-1:hover {
  background-color: rgba(60,200,250,0.5);
  /*box-shadow: -1px -1px 1px 0 rgba(60,200,250,0.5) inset, 1px 1px 1px 0 rgba(60,200,250,0.5);*/
  /*backdrop-filter: invert(50%);*/
}

.click-title-1 {
  background-color: rgba(60,200,250,1) !important;
  box-shadow:
    inset -3px -3px 5px rgba(255, 255, 255, 0.2),
    inset 3px 3px 5px rgba(0, 0, 0, 0.2) !important;
}
</style>